package com.FSS.FileList;

import java.util.Vector;

import com.FSS.config.Config;

public class ParentBox extends IBox {

	/**
	 * 
	 */
	private static final long serialVersionUID = 990952893713745568L;
	private Vector<IBox> children;
	
	public ParentBox(){
		children = new Vector<IBox>();
	}
	@Override
	public void rar() {
		String files = " ";
		for(IBox b:children){
			b.rar();
			files+=Config.rarDist+b.boxName+".rar"+" ";
		}
		try {
			Runtime rt = Runtime.getRuntime();
			Process p = rt.exec(Config.rarCmd + Config.rarDist+this.boxName + ".rar" +files);	
			streamHandle(p);
			System.out.println("cmd /C del"+files);
			rt.exec("cmd /C del"+files);
		} catch (Exception e) {
			System.out.println(e.getMessage());
		}
		
	}
	public void addChild(IBox b){
		if(!children.contains(b))
			children.add(b);
		else
			System.out.println("existed");
	}
	public void removeChild(IBox b){
		children.remove(b);
	}
	public int getChildrenSize(){
		return children.size();
	}
	public Vector<IBox> getChildren() {
		return children;
	}
}
